#! /bin/sh
script_dir=`cd "$(dirname "$0")";pwd`

killall apsta
killall monitor
killall qr_scan
killall tstreamer
killall record
killall snapshot
killall snx_record
sleep 1
$script_dir/MPTool/Network/wifiSTA/STAmode.sh > /dev/console
gpio_aud write 1 4  1
$script_dir/MPTool/Audio/aplay -D hw:0,0 -r 16000 -f S16_LE -t raw $script_dir/MPTool/raw/sd_test.wav
gpio_aud write 1 4  0


$script_dir/snapshot &
loop=0
gpio_aud write 1 4 1

while :
do 
	cp /tmp/*.jpg $script_dir -rf
	rancky=$(ls -1 $script_dir/*.jpg | sed -n "1p")
	echo $rancky > /dev/console
	if ["$rancky" = ""];then
		echo "no jpeg" > /dev/console
	else 
		echo "start upload" > /dev/console
		rancky1=$(http_curl $rancky)
		echo $rancky > /dev/console
		echo "finished upload" > /dev/console
	fi
	rm /tmp/*.jpg -rf
	sync				
	usleep 500000
done
